import { IValidation } from "./IValidation";
import { MinLengthValidator } from "../Validator/MinLengthValidator";
import { IPersonState } from "../State";

export class PersonValidation implements IValidation {
  private readonly firstNameValidator: MinLengthValidator = new MinLengthValidator(1); 
  private readonly lastNameValidator: MinLengthValidator = new MinLengthValidator(1);

  public Validate(state: IPersonState, errors: string[]): void {
    if (!this.firstNameValidator.IsValid(state.FirstName)) {
      errors.push('姓至少一个字符');
    }
    if (!this.lastNameValidator.IsValid(state.LastName)) {
      errors.push('名至少一个字');
    }
  }
}